<?php

namespace App\Services\Game;

use App\DTOS\Admin\BanListDTO;
use App\Models\Game\BanList;

class BanListService
{
    public function paginate(BanListDTO $DTO){
        $model = BanList::query();
        $page = $DTO->getPage();
        $pageSize = $DTO->getLimit();
        $createDateBegin =$DTO->getCreateDateBegin();
        $createDateEnd =$DTO->getCreateDateEnd();

        $customerId = $DTO->getCustomerId();

        if ($customerId){
            $model->where('customer_id',$customerId);
        }
        if ($createDateBegin){
            $model->where("created_at",">=",$createDateBegin);
        }
        if ($createDateEnd){
            $model->where("created_at","<=",$createDateEnd);
        }
        return $model->orderByDesc('id')->paginate($pageSize,'*','page',$page);
    }
}
